@echo off

SET DBMS_SERVER=.
SET CONNECTION_OPTIONS=-E
SET STAGING_DATABASE_NAME=EducationSystem
SET STAGING_DATABASE_USERNAME=EducationSystem

if exist ..\setConnectivity.cmd (
	call ..\setConnectivity.cmd
)

echo Disconnecting user %STAGING_DATABASE_USERNAME%...
sqlcmd -S %DBMS_SERVER% %CONNECTION_OPTIONS% -b -i disconnect.sql -v STAGING_DATABASE_USERNAME="%STAGING_DATABASE_USERNAME%" || goto FAIL
echo %STAGING_DATABASE_USERNAME% disconnected.
echo Dropping database %STAGING_DATABASE_NAME%...
sqlcmd -S %DBMS_SERVER% %CONNECTION_OPTIONS% -b -i database.sql -v STAGING_DATABASE_NAME="%STAGING_DATABASE_NAME%" || goto FAIL
echo Database dropped.
echo Dropping %STAGING_DATABASE_USERNAME% login...
sqlcmd -S %DBMS_SERVER% %CONNECTION_OPTIONS% -b -i logins.sql -v STAGING_DATABASE_USERNAME="%STAGING_DATABASE_USERNAME%" || goto FAIL
echo Login dropped.

goto SUCCESS
:FAIL
echo ERROR OCCURED. Press any key to exit...
pause >nul
goto EOF
:SUCCESS

